<?php
	session_start();
	include("/var/www/html/vivencias/conexaoBD.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Experi&ecirc;ncias do Processo de Adoecimento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="vivencias.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('imagens/stt_cadastro2.jpg','imagens/stt_banco2.jpg','imagens/stt_correcao2.jpg','imagens/stt_definI2.jpg')">
<div align="center">
  <table width="1000" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="10%" align="left" valign="top"><img src="imagens/logo.jpg" width="66" height="53"></td>
                  <td width="90%"><img src="imagens/tit1.jpg" width="612" height="28"></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr align="left" valign="middle">
                  <td colspan="3" class="nomecurso"><?php echo $_SESSION['nomeCurso'];?></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td><a href="index.php"><img src="imagens/sair.gif" width="33" height="19" border="0"></a></td>
                </tr>
                <tr align="left" valign="middle">
                  <td width="25%">&nbsp;</td>
                  <td width="22%">&nbsp;</td>
                  <td width="52%">&nbsp;</td>
                  <td width="0%">&nbsp;</td>
                  <td width="0%">&nbsp;</td>
                  <td width="1%">&nbsp;</td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr align="left" valign="top">
                  <td width="2%" background="imagens/bar_fnd_8.jpg" bgcolor="EBF4F9"><a href="relatorios.htm"><img src="imagens/mn_8.jpg" width="23" height="161" border="0"></a></td>
                  <td width="60%" align="center" bgcolor="f4f1fc">
                    <table width="816" border="0" cellpadding="0" cellspacing="0">
                      <tr align="left" valign="top">
                        <td width="10"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                        <td width="73"><a href="listagemAlunos.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('cadastro','','imagens/stt_cadastro2.jpg',1)"><img src="imagens/stt_cadastro1.jpg" name="cadastro" width="73" height="21" border="0"></a></td>
                        <td width="10"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                        <td width="52"><a href="bancoG.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('banco','','imagens/stt_banco2.jpg',1)"><img src="imagens/stt_banco1.jpg" name="banco" width="52" height="21" border="0"></a></td>
                        <td width="10"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                        <td width="81"><a href="relatorios.htm"><img src="imagens/stt_relator2.jpg" width="81" height="21" border="0"></a></td>
                        <td width="10"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                        <td width="86"><a href="correcao.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('estatisticas','','imagens/stt_correcao2.jpg',1)"><img src="imagens/stt_correcao1.jpg" name="estatisticas" width="86" height="21" border="0"></a></td>
                        <td width="1"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                        <td width="116"><a href="d.comunica.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('definicoesiniciais','','imagens/stt_definI2.jpg',1)"><img src="imagens/stt_definI1.jpg" name="definicoesiniciais" width="140" height="21" border="0"></a></td>
                        <td width="117"><img src="imagens/pix_cor7b.gif" width="84" height="5"></td>
                      </tr>
                      <tr align="left" valign="top">
                        <td colspan="11"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td width="1%"><img src="imagens/pix_cor7b.gif" width="10" height="5"></td>
                              <td width="41%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="3%">&nbsp;</td>
                              <td width="19%">&nbsp;</td>
                            </tr>
                          </table></td>
                      </tr>
                    </table>
                    <table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                      <tr bgcolor="f4f1fc" class="texttab">
                        <td align="left" valign="middle" class="titprincipal"><a href="r.completo.php" class="miudo">Voltar</a></td>
                        <td align="right" valign="middle" class="miudo">Visualizar
                          impress&atilde;o</td>
                      </tr>
                      <tr align="center" valign="middle" bgcolor="ddd9e9" class="texttab">
                        <td colspan="2" class="texto2">
                          <div align="center">
                            <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                              <tr align="left" valign="middle">
                                <td width="100%" bgcolor="9786c6" class="titprincipal"><span class="ativomenor">Relat&oacute;rio</span>
                                  <span class="titvermelho">COMPLETO INDIVIDUALIZADO</span></td>
                              </tr>
			      <?php
					$idUsuario     = $_GET['idUsuario'];
					$queryNome     = "SELECT nome FROM usuarios WHERE idUsuario='".$idUsuario."'";
					$resultadoNome = mysql_query($queryNome,$conexao);
					$objetoNome    = mysql_fetch_object($resultadoNome);
			      ?>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" bgcolor="#38708F" class="texttab">
                                      <td valign="top" bgcolor="9786c6" class="ativo"><strong><?php echo $objetoNome->nome;?></strong></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" bgcolor="a99ec6" class="texttab">
                                      <td colspan="3" valign="top"> <div align="left" class="branco"></div>
                                        <span class="ativo"> Frequ&ecirc;ncia</span></td>
                                    </tr>
				     <?php
				    		$query     = "SELECT * FROM numeroDeAcessos WHERE idUsuario='".$_GET['idUsuario']."' AND idCurso='".$_SESSION['idCurso']."' ORDER BY ano";
						$resultado = mysql_query($query,$conexao);
						while($objeto = mysql_fetch_object($resultado)){
							if($objeto->mes == "1"){
								$mes = "Janeiro";
							}else if($objeto->mes == "2"){
								$mes = "Fevereiro";
							}else if($objeto->mes == "3"){
								$mes = "Mar&ccedil;o";
							}else if($objeto->mes == "4"){
								$mes = "Abril";
							}else if($objeto->mes == "5"){
								$mes = "Maio";
							}else if($objeto->mes == "6"){
								$mes = "Junho";
							}else if($objeto->mes == "7"){
								$mes = "Julho";
							}else if($objeto->mes == "8"){
								$mes = "Agosto";
							}else if($objeto->mes == "9"){
								$mes = "Setembro";
							}else if($objeto->mes == "10"){
								$mes = "Outubro";
							}else if($objeto->mes == "11"){
								$mes = "Novembro";
							}else if($objeto->mes == "12"){
								$mes = "Dezembro";
							}

				    ?>

                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto"><?php echo $mes . '/' . $objeto->ano;?></p>
                                        </div></td>
                                      <td width="4%">&nbsp;</td>
                                      <td width="56%" valign="middle" class="texto">
                                        <?php echo $objeto->numDeAcessos .' '. "acesso(s)";?></td>
                                    </tr>
                                    <?php } ?>
                                    <!--<tr bgcolor="beb5d5" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">M&eacute;dia mensal</p>
                                        </div></td>
                                      <td valign="top">&nbsp;</td>
                                      <td valign="middle" class="texto"> 9h55min</td>
                                    </tr>-->
                                  </table></td>
                              </tr>
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" valign="middle" bgcolor="a99ec6" class="texto">
                                      <td colspan="4" class="ativo">Exerc&iacute;cios</td>
                                    </tr>
                                    <tr align="center" valign="middle" bgcolor="ddd9e9" class="texto">
                                      <td width="34%"> <p align="center" class="texto"><strong>Exerc&iacute;cio</strong></p></td>
                                      <td width="6%"> <div align="center"><strong>Data</strong></div></td>
                                      <td width="58%" bgcolor="ddd9e9"> <div align="center"><strong>Coment&aacute;rio
                                          </strong></div></td>
                                      <td width="2%"> <div align="center"><strong>Nota</strong></div></td>
                                    </tr>
				    <?php
						//Seleciona os exercicios do curso
						$queryTotExerc     = "SELECT count(idformulario) as total FROM formularios WHERE idCurso='".$_SESSION['idCurso']."'";
						$resultadoTotExerc = mysql_query($queryTotExerc,$conexao);
						$objetoTotExerc    = mysql_fetch_object($resultadoTotExerc);

						$numExercicios     = $objetoTotExerc->total;


						$queryExercicios     = "SELECT distinct formulariosRespostas.idformulario,formularios.nomefor,formulariosCorrigidos.nota,formulariosCorrigidos.comentario FROM formulariosRespostas,formularios,formulariosCorrigidos WHERE formulariosRespostas.idUsuario='".$_GET['idUsuario']."' AND formulariosRespostas.enviado=1 AND formulariosRespostas.idformulario = formularios.idformulario AND formularios.idCurso='".$_SESSION['idCurso']."' AND formulariosCorrigidos.idformulario = formulariosRespostas.idformulario AND formulariosCorrigidos.idformulario = formularios.idformulario AND formulariosCorrigidos.idUsuario = '".$_GET['idUsuario']."'";
						$resultadoExercicios = mysql_query($queryExercicios,$conexao);
						$numResultado        = mysql_num_rows($resultadoExercicios);
						while($objetoExercicios = mysql_fetch_object($resultadoExercicios)){

							$queryData      = "SELECT max(dataHora) as data FROM formulariosRespostas WHERE idformulario=$objetoExercicios->idformulario AND idUsuario='".$_SESSION['idUsuario']."'";
							$resultadoData  = mysql_query($queryData,$conexao);
							$objetoData     = mysql_fetch_object($resultadoData);

							$data = explode(" ",$objetoData->data);
							$dataCerta = ereg_replace("([0-9]{2}([0-9]{2})?)[/.-]([01]?[0-9])[/.-]([0123]?[0-9])","\\4-\\3-\\1",$data[0]);

							$somatorioNotas = $somatorioNotas + $objetoExercicios->nota;

					  ?>
                                    <tr align="center" valign="middle" bgcolor="ddd9e9" class="texto">
                                      <td> <p align="center" class="texto"><?php echo $objetoExercicios->nomefor;?></p></td>
                                      <td class="miudo"> <div align="center"><?php echo $dataCerta . ' ' . $data[1];?></div></td>
                                      <td> <div align="center"><?php echo $objetoExercicios->comentario;?></div></td>
                                      <td> <div align="center"><?php echo $objetoExercicios->nota;?></div></td>
                                    </tr>
				    <?php } ?>
                                    <tr align="center" valign="middle" bgcolor="beb5d5" class="texto">
                                      <td> <p align="center" class="texto">M&eacute;dia
                                          Exerc&iacute;cios</p></td>
                                      <td> <div align="center"></div></td>
                                      <td class="miudo"> <div align="center"></div></td>
                                      <td> <div align="center"><?php if($numExercicios > 0){ echo $media = ($somatorioNotas)/($numExercicios);}?></div></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" bgcolor="a99ec6" class="texttab">
                                      <td colspan="3" valign="top"> <div align="left" class="branco"></div>
                                        <span class="ativo"> Notas Totais</span></td>
                                    </tr>
				     <?php
						$somatorioNotas   = 0;
						$numeroExercicios = 0;
						$mediaExercicios  = 0;
						$mediaFinal       = 0;
						//Seleciona os exercicios daquele curso
						$queryExercicios     = "SELECT idformulario FROM formularios WHERE idCurso='".$_SESSION['idCurso']."'";
						$resultadoExercicios = mysql_query($queryExercicios,$conexao);
						while($objetoExercicios = mysql_fetch_object($resultadoExercicios)){
							//Seleciona as notas dos exercicios
							$queryNotaEx     = "SELECT nota FROM formulariosCorrigidos WHERE idUsuario='".$idUsuario."' AND idformulario='".$objetoExercicios->idformulario."'";
							$resultadoNotaEx = mysql_query($queryNotaEx,$conexao);
							$objetoNotaEx    = mysql_fetch_object($resultadoNotaEx);

							$somatorioNotas   = $somatorioNotas + $objetoNotaEx->nota;
							$numeroExercicios = $numeroExercicios + 1;
						}
						if($numeroExercicios > 0){
							$mediaExercicios = ($somatorioNotas)/($numeroExercicios);
						}

						$queryNotas     = "SELECT * FROM notasUsuarios WHERE idUsuario='".$idUsuario."' AND idCurso='".$_SESSION['idCurso']."'";
						$resultadoNotas = mysql_query($queryNotas,$conexao);
						while($objetoNotas = mysql_fetch_object($resultadoNotas)){

							$mediaFinal = ($mediaExercicios + $objetoNotas->blog + $objetoNotas->wiki + $objetoNotas->glossario + $objetoNotas->salaReuniao + $objetoNotas->qualitativa)/6;
				    ?>

                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">Atividade BLOG</p>
                                        </div></td>
                                      <td width="4%">&nbsp;</td>
                                      <td width="56%" valign="middle" class="texto">
                                        <?php echo $objetoNotas->blog;?>
                                      </td>
                                    </tr>
                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">Atividade SALA REUNI&Atilde;O</p>
                                        </div></td>
                                      <td>&nbsp;</td>
                                      <td valign="middle" class="texto"><?php echo $objetoNotas->salaReuniao;?></td>
                                    </tr>
                                    <!--<tr bgcolor="ddd9e9" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">Atividade FORMUL&Aacute;RIO</p>
                                        </div></td>
                                      <td>&nbsp;</td>
                                      <td valign="middle" class="texto"> <input name="textfield22" type="text" value="10.0" size="10"></td>
                                    </tr>-->
                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">Atividade WIKI</p>
                                        </div></td>
                                      <td>&nbsp;</td>
                                      <td valign="middle" class="texto"><?php echo $objetoNotas->wiki;?></td>
                                    </tr>
                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td align="right" valign="middle" class="texto">Atividade
                                        GLOSS&Aacute;RIO</td>
                                      <td valign="top">&nbsp;</td>
                                      <td valign="middle" class="texto"><?php echo $objetoNotas->glossario;?></td>
                                    </tr>
                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td align="right" valign="middle" class="texto">Avalia&ccedil;&atilde;o
                                        Qualitativa </td>
                                      <td valign="top">&nbsp;</td>
                                      <td valign="middle" class="texto"><?php echo $objetoNotas->qualitativa;?></td>
                                    </tr>
                                    <tr bgcolor="ddd9e9" class="texttab">
                                      <td align="right" valign="middle" class="texto">M&eacute;dia
                                        Exerc&iacute;cios</td>
                                      <td valign="top">&nbsp;</td>
                                      <td valign="middle" class="texto"><?php echo $mediaExercicios;?></td>
                                    </tr>
                                    <!--<tr bgcolor="ddd9e9" class="texttab">
                                      <td align="right" valign="middle" class="texto">Auto
                                        Avalia&ccedil;&atilde;o</td>
                                      <td valign="top">&nbsp;</td>
                                      <td valign="middle" class="texto"> <input name="textfield22326" type="text" value="10" size="10"></td>
                                    </tr>-->
                                    <tr bgcolor="beb5d5" class="texttab">
                                      <td valign="middle"> <div align="right">
                                          <p class="texto">M&eacute;dia total</p>
                                        </div></td>
                                      <td valign="top" bgcolor="beb5d5">&nbsp;</td>
                                      <td valign="middle" bgcolor="beb5d5" class="texto">
                                        <?php echo $mediaFinal;?>
                                      </td>
                                    </tr>
				   <?php } ?>
                                  </table></td>
                              </tr>
			     <!--
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" bgcolor="#38708F" class="texttab">
                                      <td align="left" valign="top" bgcolor="a99ec6">
                                        <span class="ativo">Execu&ccedil;&atilde;o
                                        de atividades</span></td>
                                    </tr>
                                    <tr align="center" bgcolor="#38708F" class="texttab">
                                      <td valign="top" bgcolor="ddd9e9"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td width="40%" valign="middle"> <div align="right">
                                                <p class="texto">Atividade na
                                                  Sala de Reuni&atilde;o</p>
                                              </div></td>
                                            <td width="4%">&nbsp;</td>
                                            <td width="26%" align="center" valign="middle" class="texto"><img src="imagens/ok.gif" width="25" height="24">
                                            </td>
                                            <td width="30%" align="center" valign="middle" class="texto">9,0</td>
                                          </tr>
                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td valign="middle"> <div align="right">
                                                <p class="texto">Atividade com
                                                  a Wiki</p>
                                              </div></td>
                                            <td>&nbsp;</td>
                                            <td align="center" valign="middle" class="texto"><img src="imagens/x.gif" width="25" height="22">
                                            </td>
                                            <td align="center" valign="middle" class="texto">&nbsp;</td>
                                          </tr>
                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td valign="middle"> <div align="right">
                                                <p class="texto">Atividade com
                                                  o Blog</p>
                                              </div></td>
                                            <td>&nbsp;</td>
                                            <td align="center" valign="middle" class="texto"><img src="imagens/x.gif" width="25" height="22">
                                            </td>
                                            <td align="center" valign="middle" class="texto">&nbsp;</td>
                                          </tr>
                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td valign="middle"> <div align="right">
                                                <p class="texto">Exerc&iacute;cios
                                                  (m&eacute;dia) </p>
                                              </div></td>
                                            <td>&nbsp;</td>
                                            <td align="center" valign="middle" class="texto"><img src="imagens/ok.gif" width="25" height="24">
                                            </td>
                                            <td align="center" valign="middle" class="texto">9,5</td>
                                          </tr>
                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td align="right" valign="middle" class="texto">Constru&ccedil;&atilde;o
                                              do Gloss&aacute;rio</td>
                                            <td valign="top">&nbsp;</td>
                                            <td align="center" valign="middle" class="texto"><img src="imagens/ok.gif" width="25" height="24">
                                            </td>
                                            <td align="center" valign="middle" class="texto">9,5</td>
                                          </tr>
                                          <tr bgcolor="beb5d5" class="texttab">
                                            <td valign="middle"> <div align="right">
                                                <p class="texto">M&eacute;dia</p>
                                              </div></td>
                                            <td valign="top">&nbsp;</td>
                                            <td valign="middle" class="texto">&nbsp;
                                            </td>
                                            <td align="center" valign="middle" class="texto">9,5</td>
                                          </tr>
                                        </table></td>
                                    </tr>
                                  </table></td>
                              </tr>-->
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="left" valign="middle" bgcolor="9eb5d8" class="texttab">
                                      <td width="100%" bgcolor="a99ec6"> <span class="ativo">Participa&ccedil;&atilde;o
                                        em f&oacute;rum</span></td>
                                    </tr>
                                    <tr align="center" bgcolor="d8e4f5" class="texttab">
                                      <td valign="top" bgcolor="ddd9e9"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                          <tr align="left" valign="middle" bgcolor="beb5d5" class="texto">
                                            <td class="texto2"><strong>Nome do
                                              f&oacute;rum</strong></td>
                                            <td align="center" class="texto2"><strong>N&uacute;mero
                                              de participa&ccedil;&otilde;es</strong></td>
                                          </tr>
					  <?php
						$totalForum = 0;
						$i          = 0;
						//Seleciona todos os foruns daquele curso
						$queryForum     = "SELECT idForum,titulo FROM foruns WHERE idCurso='".$_SESSION['idCurso']."'";
						$resultadoForum = mysql_query($queryForum,$conexao);
						while($objetoForum = mysql_fetch_object($resultadoForum)){
							$i = $i + 1;
							$titulo[$i]           = $objetoForum->titulo;
							//Seleciona todos os topicos daquele forum
							$queryTopicos     = "SELECT idForumTopicos FROM forumTopicos WHERE idForum='".$objetoForum->idForum."'";
							$resultadoTopicos = mysql_query($queryTopicos,$conexao);

							while($objetoTopicos = mysql_fetch_object($resultadoTopicos)){
								//Seleciona as mensagens daquele usuario naquele topico
								$queryMensagens     = "SELECT count(idForumMensagens) as total FROM forumMensagens WHERE idForumTopicos='".$objetoTopicos->idForumTopicos."' AND idRemetente='".$idUsuario."'";
								$resultadoMensagens = mysql_query($queryMensagens,$conexao);
								$objetoMensagens    = mysql_fetch_object($resultadoMensagens);
								$totalForum = $totalForum + $objetoMensagens->total;

								//$titulo[$i]           = $objetoForum->titulo;
								$numParticipacoes[$i] = $numParticipacoes[$i] + $objetoMensagens->total;
							}
						}
				          ?>

					  <?php

						for($j = 1; $j < count($titulo);$j++){

					  ?>
                                          <tr align="left" valign="middle" bgcolor="ddd9e9" class="texttab">
                                            <td width="50%"> <div>
                                                <p class="texto"><?php echo $titulo[$j];?></p>
                                              </div></td>
                                            <td width="50%" align="center" class="texto"><?php if(!$numParticipacoes[$j]){ echo 0;}else{echo $numParticipacoes[$j];}?></td>
                                          </tr>
					  <?php } ?>
                                          <tr align="left" valign="middle" bgcolor="beb5d5" class="texttab">
                                            <td class="texto">TOTAL</td>
                                            <td align="center" class="texto"><?php echo $totalForum;?></td>
                                          </tr>
                                        </table></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="left" valign="middle" bgcolor="9eb5d8" class="texttab">
                                      <td width="100%" bgcolor="a99ec6" class="ativo">
                                        Envio de mensagens</td>
                                    </tr>
                                    <tr align="center" bgcolor="d8e4f5" class="texttab">
                                      <td valign="top" bgcolor="ddd9e9"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                          <tr valign="middle" bgcolor="beb5d5" class="texto2">
                                            <td align="center"><strong>Mensagens
                                              enviadas</strong></td>
                                            <td align="center"><strong>Mensagens
                                              recebidas</strong></td>
                                          </tr>
					  <?php
						$recebidas = 0;

						//Seleciona as mensagens enviadas por aquele usuario
						$queryCorreioE     = "SELECT count(idMensagem) as enviadas FROM correioMensagens WHERE idCurso='".$_SESSION['idCurso']."' AND idRemetente='".$idUsuario."'";
						$resultadoCorreioE = mysql_query($queryCorreioE,$conexao);
						$objetoCorreioE    = mysql_fetch_object($resultadoCorreioE);

						//Seleciona todas as mensagens enviadas do curso
						$queryCorreio     = "SELECT idMensagem FROM correioMensagens WHERE idCurso='".$_SESSION['idCurso']."'";
						$resultadoCorreio = mysql_query($queryCorreio,$conexao);
						while($objetoCorreio = mysql_fetch_object($resultadoCorreio)){
							//Seleciona as mensagens recebidas naquele curso pelo usuario
							$queryCorreioR     = "SELECT lido FROM correioDestinatarios WHERE idDestinatario='".$idUsuario."' AND idMensagem='".$objetoCorreio->idMensagem."'";
							$resultadoCorreioR = mysql_query($queryCorreioR,$conexao);						if($numResultado = mysql_num_rows($resultadoCorreioR)){
								$recebidas = $recebidas + 1;
							}

						}
					  ?>
                                          <tr valign="middle" bgcolor="ddd9e9" class="texto">
                                            <td align="center"><?php echo $objetoCorreioE->enviadas;?></td>
                                            <td align="center"><?php echo $recebidas;?></td>
                                          </tr>
                                        </table></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>
                              <tr>
                                <td bgcolor="ddd9e9" class="texto2"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
                                    <tr align="center" bgcolor="#38708F" class="texttab">
                                      <td align="left" valign="top" bgcolor="a99ec6">
                                        <span class="ativo"><strong>Downloads
                                        realizados </strong></span></td>
                                    </tr>
                                    <tr align="center" bgcolor="#38708F" class="texttab">
                                      <td valign="top" bgcolor="ddd9e9"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
					<?php

					//Seleciona todos os recursos de aprendizagem do curso
					$query1     = "SELECT * FROM recursosAprendizagem WHERE idCurso='".$_SESSION['idCurso']."'";
					$resultado1 = mysql_query($query1,$conexao);
					while($objeto1 = mysql_fetch_object($resultado1)){
						//Verifica se o aluno selecionado fez o download do objeto selecionado
						$query2     = "SELECT * FROM downloads WHERE downloads.idUsuario='".$idUsuario."' AND idObjeto= '".$objeto1->idRecurso."'";
						$resultado2 = mysql_query($query2,$conexao);
						if($resultado2){
							if($num_result = mysql_num_rows($resultado2)){
								$imagem = "imagens/ok.gif";
							}else{
								$imagem = "imagens/x.gif";
							}
							$objeto2 = mysql_fetch_object($resultado2);

						}else{
							die('Erro:' . mysql_error());
						}

						$caminho = explode('/',$objeto1->caminho);
				?>

                                          <tr bgcolor="ddd9e9" class="texttab">
                                            <td width="44%" valign="middle"> 
					      <div align="right">
                                                <p class="texto">
							<?php 
								if(strlen($caminho[3]) > 40){
									echo substr($caminho[3], 0, 40) . "...";
								}else{
									echo $caminho[3];			
								}
							?>
						</p>
                                              </div>
                                            </td>
                                            <td width="27%" align="center" valign="middle" class="texto"><img src="<?php echo $imagem;?>" width="25" height="24">
                                            </td>
                                            <td width="29%" align="center" valign="middle" class="miudo">
						<?php 
							$dataHora = explode(" ", $objeto2->dataHora);	
							$data     = ereg_replace("([0-9]{2}([0-9]{2})?)[/.-]([01]?[0-9])[/.-]([0123]?[0-9])","\\4-\\3-\\1",$dataHora[0]);
							echo $data . " " .$dataHora[1];								
						?>
					    </td>
                                          </tr>
                                          <?php } ?>
                                        </table></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <!--<tr>
                                <td bgcolor="f4f1fc" class="texto2">&nbsp;</td>
                              </tr>-->

                            </table>
                          </div></td>
                      </tr>
                    </table>
                    <p>&nbsp;</p></td>
                  <td width="0%" align="right" background="imagens/bar_fnd_7.jpg"><a href="info.php"><img src="imagens/mn_7.jpg" width="23" height="137" border="0"></a>
                  </td>
                  <td width="8%" align="right" background="imagens/bar_fnd_6.jpg"><a href="esppess.php"><img src="imagens/mn_6.jpg" width="23" height="156" border="0"></a>
                  </td>
                  <td width="4%" align="right" background="imagens/bar_fnd_5.jpg"><a href="comunicacao.php"><img src="imagens/mn_5.jpg" width="23" height="146" border="0"></a>
                  </td>
                  <td width="5%" align="right" background="imagens/bar_fnd_4.jpg"><a href="banco.php"><img src="imagens/mn_4.jpg" width="23" height="219" border="0"></a>
                  </td>
                  <td width="4%" align="right" background="imagens/bar_fnd_3.jpg"><a href="ferramentasTrabalho.php"><img src="imagens/mn_3.jpg" width="23" height="249" border="0"></a>
                  </td>
                  <td width="2%" align="right" background="imagens/bar_fnd_2.jpg"><a href="conteudo.php"><img src="imagens/mn_2.jpg" width="23" height="113" border="0"></a></td>
                  <td width="15%" align="right" background="imagens/bar_fnd_1.jpg" bgcolor="F1FEF9">
                    <p><a href="principal.php"><img src="imagens/mn_1.jpg" width="23" height="103" border="0"></a></p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>
</body>
</html>
